def range_check(elems, min, max, msg):
    if any((e < min or e > max for e in elems)):
        raise ValueError(msg)
    return list(elems)

class Schedule:
    def __init__(self,
                 years,
                 months,
                 days,
                 hours,
                 minutes):
        self.years = years
        self.months = range_check(months, 1, 12, 
            'month must be in range 1-12')
        self.days = range_check(days, 1, 31,
            'day must be in range 1-7')
        self.hours = range_check(hours, 0, 23,
            'hour must be in range 0-23')
        self.minutes = range_check(minutes, 0, 59,
            'minute must be in range 0-59')
